﻿using SHKF.B2C.Model.Dto.WorkingCenter;
using SHKF.B2C.Model.Entity.WorkingCenter;
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace SHKF.B2C.Mannage.AdminUI.View.WorkingCenter
{
    /// <summary>
    /// 选择分仓
    /// </summary>
    public partial class frmSearchDataWarehous : Window
    {
        public frmSearchDataWarehous()
        {
            InitializeComponent();
        }

        private void btnFindDataWarehous_Click(object sender, RoutedEventArgs e)
        {
            LoadDataWareHouse();
        }

        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if( this.dgvDataWarehous.SelectedItem != null)
            {
                this.DialogResult = true;
                this.Close();
            }
        }

        private async void LoadDataWareHouse()
        {
            DataWarehousInfoListDto dto = await GL.HttpClientManage.QueryDataWarehousInfoList(this.txtKeyWord.Text);
            if (dto.error == null)
            {
                this.dgvDataWarehous.ItemsSource = dto.data;
            }
            else
            {
                MessageBox.Show(dto.error.msg);
            }
        }

        public DataWarehousInfoEntity Data
        {
            get
            {
                DataWarehousInfoEntity info = (DataWarehousInfoEntity)this.dgvDataWarehous.SelectedItem;
                return info;
            }
             
        }
    }
}
